<?php

namespace App\Http\Controllers\VideoAdmin;

use App\Models\video\BroadcasterRelationModel;
use App\Models\video\VideoUserModel;
use App\Http\Controllers\Admin\BaseController;
use Illuminate\Http\Request;

class UserController extends BaseController
{
    public function __construct(Request $request)
    {
        parent::__construct($request);
    }

    // 获取设置up主的用户列表
    public function getListBySetUp(Request $request){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $data = VideoUserModel::getFields("id,nickname,mobile", [['user_type', '<>', 1], ['mall_id', '=', $request->mallData['id']]], false, false);
        if($request->id){
            $userData = BroadcasterRelationModel::getFields("user_id", ['broadcaster_id' => $request->id], false, false);
            $userId = [];
            foreach ($userData as $item){
                $userId[] = $item["userId"];
            }
            $data = array_merge($data, VideoUserModel::query()->select("id", "nickname", "mobile")->whereIn("id", $userId)->get()->toArray());
        }
        $this->returnData["data"] = $data;
        return $this->return_result($this->returnData);
    }
}